package demo.practice.leetcode_msjd;

import java.util.Stack;

public class Msjd0305 {
}


class SortedStack {

    Stack<Integer> stack;
    public SortedStack() {
        stack= new Stack<>();
    }

    public void push(int val) {
        if(stack.empty()|| stack.peek()>=val){
            stack.push(val);
            return;
        }

        int top = stack.pop();
        push(val);
        stack.push(top);
    }

    public void pop() {
       if (!isEmpty())
           stack.pop();
    }

    public int peek() {
        return stack.peek();
    }

    public boolean isEmpty() {
        return stack.isEmpty();
    }
}